package com.dg11185.nearshop.baidumap;

import android.os.Parcel;
import android.os.Parcelable;

import com.dg11185.nearshop.net.entity.MerchantInfo;
import com.dg11185.nearshop.net.entity.MerchantItem;

/**
 * 封装该地图接收的数据类型
 * 
 * @author：Daibo
 * @time：2014-5-11 下午3:05:26
 */
public class EntityShopData implements Parcelable {
    public String shopLatitude = "";

    public String shopLongitude = "";

    public String shopIndustryId = "";

    public String shopTitle = "";

    public String shopImg = "";

    public String shopRate = "";

    public String shopAddress = "";

    public String shopCity = "";

    public String shopId = "";

    public EntityShopData() {

    }

    public EntityShopData(MerchantInfo info) {
        this.shopLongitude = info.longitude;
        this.shopLatitude = info.latitude;
        this.shopIndustryId = info.industryId;
        this.shopTitle = info.merchantName;
        this.shopImg = info.midPhotoUrl;
        this.shopRate = info.avgRating;
        this.shopAddress = info.address;
        this.shopCity = "东莞";
        this.shopId = info.merchantId;
    }

    public EntityShopData(MerchantItem item) {
        this.shopLongitude = item.longitude;
        this.shopLatitude = item.latitude;
        this.shopIndustryId = item.industryId;
        this.shopTitle = item.merchantName;
        this.shopImg = item.midPhotoUrl;
        this.shopRate = item.avgRating;
        this.shopAddress = item.address;
        this.shopCity = "东莞";
        this.shopId = item.merchantId;
    }

    public EntityShopData(Parcel in) {
        String[] data = new String[9];
        in.readStringArray(data);
        this.shopLatitude = data[0];
        this.shopLongitude = data[1];
        this.shopIndustryId = data[2];
        this.shopTitle = data[3];
        this.shopImg = data[4];
        this.shopRate = data[5];
        this.shopAddress = data[6];
        this.shopCity = data[7];
        this.shopId = data[8];
    }

    public static final Parcelable.Creator<EntityShopData> CREATOR = new Creator<EntityShopData>() {

        @Override
        public EntityShopData createFromParcel(Parcel source) {
            return new EntityShopData(source);
        }

        @Override
        public EntityShopData[] newArray(int size) {
            return new EntityShopData[size];
        }
    };

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeStringArray(new String[] { this.shopLatitude, this.shopLongitude, this.shopIndustryId,
                this.shopTitle, this.shopImg, this.shopRate, this.shopAddress, this.shopCity, this.shopId

        });
    }
}
